-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add commutator control based on swing-twist decomposition #2
Conversation
83d756d
to
e7403b9
Compare
@jonnew Thanks for clarifying the additional functionality of the commutator device. Given this I agree we should refactor the Detailed reasons below:
While it is possible to format the JSON string with the I don't currently see any particular advantage of exposing the internal JSON strings, especially given the protocol does not comply to an existing standard and there is little cost or complexity added in doing this abstraction.
Input validation is definitely an important consideration. Similar to the above, having the packaged node would make it much easier to upgrade legacy workflows to benefit from improved validation. For example, in the future we could extend this operator to drop or throw if inputs are sent too fast, etc.
This is where having a general The easiest way to do this would have been for the commutator to use one of the standard control protocols already integrated into bonsai such as Harp or even ONI itself. This would have allowed us to leverage a bunch of existing infrastructure for configuration, control, logging and synchronization with other devices. In fact, if it was Harp we could even have generated the entire Bonsai interface automatically. All the questions you asked about how to dynamically parameterize device configuration and having multiple control streams have already been solved for all Harp devices for example. I don't know what microcontroller the commutator uses, but there is now an existing Harp core for the RP2040 (https://github.com/AllenNeuralDynamics/harp.core.rp2040) which would have been perfect for this. A simple version could also be designed on top of other microcontroller architectures, including software forms of clock synchronization which have been implemented for other devices. Assuming this is not possible for the current hardware / firmware combination:
This is definitely a possibility and I think we could make this pattern work by using a
I'm not sure I understood this suggestion correctly, but I'm interpreting this to be the same pattern we use for the Harp I think this would definitely be flexible enough for all present and future needs. Basically in this pattern we need just two concepts:
I think the last two bullet points would on their own also justify having a Even though The last point is optional but easy to implement and important for validation to ensure the commutator does not go into an undefined state by accidentally receiving gibberish data from upstream.
This could actually be done very easily by linking both properties via the same
Seeing the manual control of the motor with keys and LED control functionality added to the It feels there are currently two things being conflated in this package:
I feel that 2. could just as easily be provided simply as an example in the commutator docs, with no need for an embedded workflow. This recommended example usage workflow could be updated regularly as we improve the pattern without requiring updates to the commutator package. That said, I don't disagree we could also make it into an embedded workflow in the package, although in that case I feel it should be fairly minimalistic, e.g. without assuming specific keys or options, since the more we assume the higher is the risk that it will not work for someone's specific workflow. |
- Minor changes to description text - Rename QuaternionTwistController -> QuaternionToTwist because it does not control anything
Summary
A common pattern of commutation is to use rotation measurements from a BNO055 or similar device to compute a feedback control signal for stabilizing twist in the tether.
This PR introduces a high-level operator
AutoCommutator
which provides a reusable solution for this pattern. Additionally, we introduce two operators to allow low-level interface with the commutator, and to compute the feedback signal in isolation. This allows composing custom commutation solutions where the control signal may be combined with manual operation, or to enable fine-grained rate control and logging, as demonstrated in the final example.Operators
TurnMotor
: the low-level interface to the motor, operated in units of full turns, in the range [-1, 1]. The input is a sequence of turn values. The operator internally formats and sends to a serial port a sequence of JSON strings used to drive the motor controller.QuaternionTwistController
: calculates the feedback control signal to stabilize twisting in the tether about the specified axis from a series ofQuaternion
rotation measurements. The twist about the specified axis is used to compute the differential feedback signal which is then normalized into units of turns.AutoCommutator
: an embedded workflow which samples the rotation measurements at 10 Hz, computes the differential feedback signal and drives the motor at the specified serial port.Examples
Driving the commutator with a BNO055 from the Onix1 library
Logging BNO055 measurement timestamps with each command
Fixes #1